package com.executor.gateway.core;

import com.alibaba.fastjson.JSONArray;
import com.executor.gateway.core.util.BloomFilterUtils;
import com.executor.gateway.model.po.IpList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Auther: miaoguoxin
 * @Date: 2019/4/1 21:43
 * @Description: redis topic消息接收
 */
@Component
@Slf4j
public class RedisTopicMessageReceiver {
    @Autowired
    private ApiConfigManager apiConfigManager;
    
    @Autowired
    private BloomFilterUtils bloomFilterService;

    /**
     * 接收api配置信息
     *
     * @param message 消息
     */
    public void receiveApiMessage(String message) {
        log.info("receive api message:{}", message);
    }

    /**
     * 接收route配置信息
     *
     * @param message 消息
     */
    public void receiveRouteMessage(String message) {
        log.info("receive route message:{}", message);
    }

    /**
     * 接收IP列表配置信息
     *
     * @param message 消息
     */
    /*public void receiveIpListsMessage(String message) {
        log.info("receive ip lists message:{}", message);
        try {
            List<IpList> ipLists = JSONArray.parseArray(message, IpList.class);
            
            // 更新布隆过滤器
            bloomFilterService.initBloomFilterWithIpListObjects(ipLists);
            
        } catch (Exception e) {
            log.error("Failed to process ip lists message", e);
        }
    }*/
}